package com.gujia.rabbitmq.simple;

import com.gujia.rabbitmq.util.ConnectionUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Sender {

    private static final String QUEUE_NAME="test_simple_queue";

    public static void main(String[] args) throws IOException, TimeoutException {
       //获取一个连接
       Connection connection = ConnectionUtils.getConnction();

       //从连接中获取一个通道
        Channel channel = connection.createChannel();
        //创建声明队列
        channel.queueDeclare(QUEUE_NAME,false,false,false,null);

        String msg="hello simple！";
      //  while(true){
            channel.basicPublish("",QUEUE_NAME,null,msg.getBytes());
            System.out.println("----send msg:"+msg);
       // }

        channel.close();
        connection.close();

    }
}
